package com.stx.test;

import java.util.Random;

/**
 * packageName com.stx.test
 *
 * @author YangYi
 * @className Demo
 * @date 2025/9/8
 * @description TODO
 */
public class Demo {
    public static void main(String[] args){
        /**
         * 字符串定义方式：
         * 1、直接进行赋值
         * 2、使用new进行赋值
         */
        String s1 = "Hello World";
        String s2 = new String("Hello World");
        String s3 = "Hello World";
        /**
         * == 基本数据类型是比较的值，引用类型比较的是地址
         * equals 比较的地址的内容
         */
        System.out.println(s1 == s2);
        System.out.println(s1 == s3);
        String s4 = "Hello " + "World";
        System.out.println(s1 == s4);
        String s5 = "Hello ";
        String s6 = s5 + "World";
        // s6是会重新分配内存，而不是去常量池里找
        System.out.println(s1 == s6);

        Random random = new Random();
        int i = random.nextInt(10);
        while (i != 3){
            System.out.println(i);
            i = random.nextInt(10);
        }
    }
}
